package com.uniview.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.uniview.dao.CCRelationDao;
import com.uniview.dao.OrderCCRelationDao;
import com.uniview.entity.po.CCRelation;
import com.uniview.entity.po.OrderCCRelation;
import com.uniview.service.CCRelationService;

@Service("ccRelationService")
public class CCRelationServiceImpl implements CCRelationService {

	@Autowired
	private CCRelationDao ccRelationDao;
	
	@Autowired
	private OrderCCRelationDao orderCCRelationDao;
	
	@Override
	public List<CCRelation> findCCByOwner(String owner) {
		try {
			return ccRelationDao.findCCByOwner(owner);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public boolean removeCCByOwner(String owner) {
		try {
			return ccRelationDao.removeCCByOwner(owner);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean saveCCRelation(List<CCRelation> list) {
		try {
			return ccRelationDao.save(list, 20);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean saveOrderCCRelation(List<OrderCCRelation> list) {
		try {
			return orderCCRelationDao.save(list, 20);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public List<OrderCCRelation> findOrderCCRelationByOrderId(Integer orderId) {
		try {
			return orderCCRelationDao.findOrderCCRelationByOrderId(orderId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
